package cl.orangepeople.whyem.portal.backend.api.impl;

import java.math.BigDecimal;

import org.apache.commons.lang3.ArrayUtils;

import cl.orangepeople.whyem.portal.backend.api.ClientDataService;
import cl.orangepeople.whyem.portal.backend.dto.client.ClientIDDTO;
import cl.orangepeople.whyem.portal.backend.dto.client.ClientIDData;
import cl.orangepeople.whyem.portal.backend.dto.client.ClientIDSearchBean;

public class ClientDataServiceImpl implements ClientDataService {
    private static String[] clientsID;

    static {
	clientsID = new String[] { "15956647", "158011638", "111111111", "15801163", "11111111", "222222222", "22222222" };
    }

    public ClientIDSearchBean getClientData(ClientIDDTO clientData) {
	ClientIDSearchBean bean = new ClientIDSearchBean();
	ClientIDData newClientData = new ClientIDData();

	if (ArrayUtils.contains(clientsID, clientData.getClientID())) {
	    bean.setReturnCode(0);
	    newClientData.setClientID(new BigDecimal(clientData.getClientID()));
	    newClientData.setClientName("Paolo Mezzano");
	    bean.setClientData(newClientData);
	} else {
	    bean.setReturnCode(-1);
	    bean.setClientData(newClientData);
	}

	return bean;
    }
}